package com.lbiuse.wx.util;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class WechatConfigUtil {
	private static Properties properties = new Properties();

	static {
		try {
			properties.load(WechatConfigUtil.class.getClassLoader()
					.getResourceAsStream("config.properties"));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static String getString(String key) {
		return properties.getProperty(key);
	}

	public static Integer getInteger(String key) {
		Integer i = null;
		try {
			String value = getString(key);
			i = Integer.parseInt(value);
		} catch (Exception e) {
			i = null;
		}
		return i;
	}

	public static Double getDouble(String key) {
		Double d = null;
		try {
			String value = getString(key);
			d = Double.parseDouble(value);
		} catch (Exception e) {
			d = null;
		}
		return d;
	}

	public static Float getFloat(String key) {
		Float f = null;
		try {
			String value = getString(key);
			f = Float.parseFloat(value);
		} catch (Exception e) {
			f = null;
		}
		return f;
	}

	public static boolean getBoolean(String key) {
		boolean b = false;
		try {
			String value = getString(key);
			b = Boolean.parseBoolean(value);
		} catch (Exception e) {
			b = false;
		}
		return b;
	}

	public static String getAppId() {
		return getString("wx.appId");
	}
	
	public static String getShopSecrect() {
		return getString("wx.shopSecrect");
	}

	public static String getSecrect() {
		return getString("wx.appSecrect");
	}
	
	public static String getShopId() {
		return getString("wx.shopId");
	}

	public static String getPayNotifyUrl() {
		// TODO Auto-generated method stub
		return getString("wx.notify_url");
	}
}
